class Solution {
public:
    int lengthOfLastWord(const char *s) {
        if (s==NULL) return 0;
        int ans=0;
        for (const char *p=s, *start=NULL;*p;++p)
            if (*p==' ')
                start=NULL;
            else {
                if (start==NULL) start=p;
                ans=(p-start)+1;
            }
        return ans;
    }
};
